﻿#include "OperGeometryNode.h"
#include "GUIFrame/MainWindow.h"
#include "FITK_Kernel/FITKAppFramework/FITKGlobalData.h"
#include "FITK_Kernel/FITKAppFramework/FITKAppFramework.h"
#include "FITK_Interface/FITKInterfaceGeometry/FITKAbsGeoModelPoint.h"
#include "GUIDialog/GUIGeometryDialog/GUIGeometryNodeDialog.h"
#include "OperatorsInterface/GraphEventOperator.h"

#include"GUIDialog\GUIGeometryDialog\GUIGeometryIntersectionDialog.h"
#include <QMessageBox>

namespace ModelOper
{
    bool OperGeometryNode::execGUI()
    {
        if (!_emitter)return false;
        //获取动作名称
        QString actionName = _emitter->objectName();
        if (actionName == "actionNodeCoord")
            this->createGeoPointCreateOper();
        else if (actionName == "actionNodeOfIntersection")
            this->createGeoIntersectionCreateOper();
        return false;
    }

    bool OperGeometryNode::execProfession()
    {
        int objID = -1;
        this->argValue("objID", objID);
        //获取三维可视对象数据-用于渲染数据对象
        EventOper::GraphEventOperator* graphOper = FITKOPERREPO->getOperatorT<EventOper::GraphEventOperator>("GraphPreprocess");
        if (graphOper == nullptr)return false;
        graphOper->updateGraph(objID);
        return true;
    }

    void OperGeometryNode::createGeoPointCreateOper()
    {
        //主界面
        QWidget* mw = FITKAPP->getGlobalData()->getMainWindow();
        if (!mw) return;
        //创建界面
        GUI::GUIGeometryNodeDialog* dialog = new GUI::GUIGeometryNodeDialog(this, mw);
        if (!dialog) return;
        connect(dialog, &QDialog::accepted, this, &OperGeometryNode::execProfession);
        dialog->show();
    }

    void OperGeometryNode::createGeoIntersectionCreateOper()
    {
        //主界面
        QWidget* mw = FITKAPP->getGlobalData()->getMainWindow();
        if (!mw) return;
        //创建界面
        GUI::GUIGeometryIntersectionDialog* dialog = new GUI::GUIGeometryIntersectionDialog(this, mw);
        if (!dialog) return;
        connect(dialog, &QDialog::accepted, this, &OperGeometryNode::execProfession);
        dialog->show();
    }
    void OperGeometryNode::editGeoPointCreateOper()
    {

    }
}

